
/**
 * 枚举类型单例模式
 */
public enum SingletonDemo05 {
    INSTANCE;

    public SingletonDemo05 getInstance() {
        return INSTANCE;
    }
}

class SingleTonTest05 {
    public static void main(String[] args) {
        SingletonDemo05 instance01 = SingletonDemo05.INSTANCE;
        SingletonDemo05 instance02 = SingletonDemo05.INSTANCE;
        System.out.println(instance01 == instance02);  //返回true,代表同一个对象
    }
}
